package common

// ------------------------------------------------------------------------------
// Module
// ------------------------------------------------------------------------------
type CreateModuleParam struct {
	Name       string `json:"name" binding:"required"`
	Parent     uint   `json:"parent" binding:"omitempty"`
	Desc       string `json:"desc" binding:"required"`
	CreateType string `json:"createType" binding:"required"`
	ModuleType string `json:"moduleType" binding:"required"`
	App        string `json:"app" binding:"required"`
	Space      string `json:"space" binding:"required"`
}

type CreateModuleRspData struct {
	ID uint `json:"id"`
}

type ImportModuleParam struct {
	Parent string
	Name   string
	Desc   string
}

type EditModuleParam struct {
	ID     uint
	Name   string `json:"name" binding:"required"`
	Desc   string `json:"desc" binding:"required"`
	Parent uint   `json:"parent" binding:"omitempty"`
}

type BatchEditModuleParam struct {
	Modules []uint `json:"modules" binding:"required"`
	Parent  uint   `json:"parent" binding:"required"`
}

type DeleteModuleParam struct {
	ID uint `json:"id" binding:"required"`
}

type ModuleInfo struct {
	ModuleID    uint   `json:"moduleId" binding:"required"`
	Name        string `json:"name" binding:"required"`
	Desc        string `json:"desc" binding:"required"`
	ParentID    uint   `json:"parentId" binding:"required"`
	ParentName  string `json:"parentName" binding:"required"`
	CreateType  string `json:"createType" binding:"required"`
	ModuleType  string `json:"moduleType" binding:"required"`
	App         string `json:"app" binding:"required"`
	Space       string `json:"space" binding:"required"`
	Position    string `json:"position" binding:"required"`
	ActiveState string `json:"activeState" binding:"required"`
	DependState uint   `json:"dependState" binding:"required"`
	CreateTime  string `json:"createTime" binding:"required"`
	UpdateTime  string `json:"updateTime" binding:"required"`
	DependCount uint   `json:"dependCount" binding:"required"`
}

type GetDescendantsResult struct {
	Parent      ModuleInfo   `json:"parent" binding:"required"`
	Descendants []ModuleInfo `json:"descendants" binding:"required"`
}

type DependencyInfo struct {
	Name       string `json:"name" binding:"required"`
	Desc       string `json:"desc" binding:"required"`
	Protocol   string `json:"protocol" binding:"required"`
	TargetType string `json:"targetType" binding:"required"`
	TargetID   string `json:"targetId" binding:"required"`
	State      uint   `json:"state" binding:"required"`
	ModuleID   uint   `json:"moduleId" binding:"required"`
	ModuleName string `json:"moduleName" binding:"required"`
}

type ReportInfo struct {
	Instance     string           `json:"instance" binding:"required"`
	Type         string           `json:"type" binding:"required"`
	App          string           `json:"app" binding:"required"`
	Space        string           `json:"space" binding:"required"`
	Data         string           `json:"data"`
	Dependencies []DependencyInfo `json:"dependencies" binding:"required"`
}

// ------------------------------------------------------------------------------
// Topo Module
// ------------------------------------------------------------------------------

type TopoLink struct {
	Protocol   string `json:"protocol" binding:"required"`
	ModuleID   uint   `json:"moduleId" binding:"required"`
	ModuleName string `json:"moduleName" binding:"required"`
	State      uint   `json:"state" binding:"required"`
}

type TopoModuleInfo struct {
	ID     uint       `json:"id" binding:"required"`
	Name   string     `json:"name" binding:"required"`
	Desc   string     `json:"desc" binding:"required"`
	Parent uint       `json:"parent" binding:"required"`
	State  string     `json:"state" binding:"required"`
	Links  []TopoLink `json:"links" binding:"required"`
}

type GetTopoModuleListResult struct {
	Modules []TopoModuleInfo `json:"modules" binding:"required"`
}

type UpdateTopoModuleParam struct {
	TopoViewID uint     `json:"topoViewId" binding:"required"`
	Modules    []string `json:"modules" binding:"required"`
}

// ------------------------------------------------------------------------------
// Topo Rule
// ------------------------------------------------------------------------------
type CreateTopoRuleParam struct {
	TopoViewID  uint   `json:"topoViewId" binding:"required"`
	Desc        string `json:"desc" binding:"required"`
	Regex       string `json:"regex" binding:"required"`
	Replacement string `json:"replacement" binding:"required"`
}

type CreateTopoRuleRspData struct {
	ID uint `json:"id"`
}

type DeleteTopoRuleParam struct {
	ID uint `json:"id"`
}

type TopoRuleInfo struct {
	ID          uint   `json:"id" binding:"required"`
	TopoViewID  uint   `json:"topoViewId" binding:"required"`
	Desc        string `json:"desc" binding:"required"`
	Regex       string `json:"regex" binding:"required"`
	Replacement string `json:"replacement" binding:"required"`
}

// ------------------------------------------------------------------------------
// Topo View
// ------------------------------------------------------------------------------
type CreateTopoViewParam struct {
	Name     string `json:"name" binding:"required"`
	Desc     string `json:"desc" binding:"required"`
	ModuleID uint   `json:"moduleId" binding:"required"`
}

type CreateTopoViewRspData struct {
	ID uint `json:"id"`
}

type EditTopoViewParam struct {
	ID   uint   `json:"id" binding:"required"`
	Name string `json:"name" binding:"required"`
	Desc string `json:"desc" binding:"required"`
}

type DeleteTopoViewParam struct {
	ID uint `json:"id" binding:"required"`
}
type TopoViewInfo struct {
	ID         uint   `json:"id" binding:"required"`
	Name       string `json:"name" binding:"required"`
	Desc       string `json:"desc" binding:"required"`
	ModuleID   uint   `json:"moduleId" binding:"required"`
	CreateTime string `json:"createTime" binding:"required"`
	ModuleSize uint   `json:"moduleSize" binding:"required"`
	RuleSize   uint   `json:"ruleSize" binding:"required"`
}

// ------------------------------------------------------------------------------
// Report Rule
// ------------------------------------------------------------------------------

type ReportRuleInfo struct {
	RuleID     uint   `json:"ruleId" binding:"required"`
	ModuleID   uint   `json:"moduleId" binding:"required"`
	Desc       string `json:"desc" binding:"required"`
	MatchType  string `json:"matchType" binding:"required"`
	MatchRule  string `json:"matchRule" binding:"required"`
	ParentId   uint   `json:"parentId" binding:"required"`
	ParentName string `json:"parentName" binding:"required"`
	CreateTime string `json:"createTime" binding:"required"`
}

type CreateReportRuleParam struct {
	ModuleID  uint   `json:"moduleId" binding:"required"`
	Desc      string `json:"desc" binding:"required"`
	MatchType string `json:"matchType" binding:"required"`
	MatchRule string `json:"matchRule" binding:"required"`
	Parent    string `json:"parent" binding:"required"`
}

type CreateReportRuleRspData struct {
	RuleID uint `json:"ruleId" binding:"required"`
}

type EditReportRuleParam struct {
	RuleID    uint   `json:"ruleId" binding:"required"`
	Desc      string `json:"desc" binding:"required"`
	MatchType string `json:"matchType" binding:"required"`
	MatchRule string `json:"matchRule" binding:"required"`
	Parent    string `json:"parent" binding:"required"`
}

type DeleteReportRuleParam struct {
	RuleID uint `json:"ruleId" binding:"required"`
}

type ImportReportRuleParam struct {
	Desc      string
	MatchType string
	MatchRule string
	Parent    string
}

// ------------------------------------------------------------------------------
// Event
// ------------------------------------------------------------------------------

type CreateEventParam struct {
	RootModuleID uint   `json:"rootModuleId" binding:"required"`
	ModuleID     uint   `json:"moduleId" binding:"required"`
	ModuleName   string `json:"moduleName" binding:"required"`
	EventType    string `json:"eventType" binding:"required"`
	Attribute    string `json:"attribute" binding:"required"`
}

type CreateEventRspData struct {
	EventID uint `json:"eventId" binding:"required"`
}

type DeleteEventParam struct {
	EventID uint `json:"eventId" binding:"required"`
}

type BatchDeleteEventParam struct {
	Events []uint `json:"events" binding:"required"`
}

type GetEventListParam struct {
	RootModuleID uint   `json:"rootModuleId" binding:"required"`
	ModuleName   string `json:"moduleName"`
	EventType    string `json:"eventType"`
	PageSize     uint   `json:"pageSize" binding:"required"`
	PageIndex    uint   `json:"pageIndex" binding:"required"`
	StartTime    string `json:"startTime"`
	EndTime      string `json:"endTime"`
}

type EventInfo struct {
	EventID      uint   `json:"eventId" binding:"required"`
	RootModuleID uint   `json:"rootModuleId" binding:"required"`
	ModuleID     uint   `json:"moduleId" binding:"required"`
	ModuleName   string `json:"moduleName" binding:"required"`
	EventType    string `json:"eventType" binding:"required"`
	Attribute    string `json:"attribute" binding:"required"`
	CreateTime   string `json:"createTime" binding:"required"`
}

type GetEventListRsp struct {
	PageSize  uint        `json:"pageSize" binding:"required"`
	PageIndex uint        `json:"pageIndex" binding:"required"`
	TotalSize uint        `json:"totalSize" binding:"required"`
	Events    []EventInfo `json:"events" binding:"required"`
}
